package com.lsh.oms.core.service.aftersale.impl;

import com.alibaba.fastjson.JSON;
import com.lsh.oms.core.dao.afterSales.OrderAfterSalesDao;
import com.lsh.oms.core.model.after.OrderAfterSales;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 *
 * @author xuzhan
 * @date 16/10/10
 */
@Service("afterSalesService")
@Transactional(rollbackFor = RuntimeException.class)
public class AfterSalesService extends AbstractAfterSales<OrderAfterSales> {

    @Resource
    private OrderAfterSalesDao orderAfterSalesDao;


    @Override
    public void insert(OrderAfterSales vo) {
        orderAfterSalesDao.insertVo(vo);
    }
    @Override
    public void update(OrderAfterSales vo) {
        orderAfterSalesDao.updateVo(vo);
    }
    @Override
    public OrderAfterSales queryVoByOrdercode(OrderAfterSales vo) {
        return orderAfterSalesDao.queryVoByOrdercode(vo);
    }

    @Override
    public OrderAfterSales parse(String json) throws Exception {
        return JSON.parseObject(json, OrderAfterSales.class);
    }

    @Override
    public Integer updateDel(OrderAfterSales oas) {
        return orderAfterSalesDao.updateDel(oas);
    }

    @Override
    public List<OrderAfterSales> loadAfterSales(Long orderCode) {
        return this.orderAfterSalesDao.findListByOrderCode(orderCode);
    }

    @Override
    public OrderAfterSales findOne(String afterSalesCode) {
        return orderAfterSalesDao.findOne(afterSalesCode);
    }

    @Override
    public boolean recreateAfterSales(List list, OrderAfterSales afterSales) {
        this.orderAfterSalesDao.deleteByList(list);
        return this.orderAfterSalesDao.insertVo(afterSales) > 0;
    }

}
